package testing.src.vineet.java.code.probs;

/**
 *  Divide and concur algorithm
 */
public class Xpown 
{
	public static void main(String argv[])
	{
		Xpown cal = new Xpown();
		System.out.println(cal.pow(5,3));
	}
	
	long pow(long x,long n)
	{
		if(n == 0)
		{
			return 1;
		}
		if(n == 1)
		{
			return x;
		}

		long res = pow(x,n/2);
		if( n%2 == 0)
		{
			return res * res;
		}
		else
		{
			return res * res * x;
		}
	}
}
